﻿using System;
using System.Collections.Generic;
using AMM.CustomClassLibrary;
using AMM.DataAccess.Config;
using AMM.Model;

namespace AMM.Business.Config {
    public class ConfigurationProcessor : BaseProcessor {

        private ConfigurationRepository _configurationRepository;

        public ConfigurationProcessor() {
            this._configurationRepository = new ConfigurationRepository();
        }

        public Configuration FetchConfigurationByKeyCode(string keyCode) {
            try {
                return this._configurationRepository.FetchConfigurationByKeyCode(keyCode);
            }
            catch (Exception ex) {
                Logger.Error(ex.Message, ex);
                throw this.BuildException("获取指定基本配置资料数据失败！");
            }
        }

        public List<Configuration> FetchConfigurationList() {
            try {
                return this._configurationRepository.FetchConfigurationList();
            }
            catch (Exception ex) {
                Logger.Error(ex.Message, ex);
                throw this.BuildException("获取基本配置资料数据失败！");
            }
        }

        public void Update(Configuration config) {
            try {
                this._configurationRepository.Update(config);
            }
            catch (Exception ex) {
                Logger.Error(ex.Message, ex);
                throw this.BuildException("更新高级设置操作失败！");
            }
        }
    }
}
